package com.migraine.mapper;

import com.migraine.model.Message;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

public interface MessageMapper {
    int deleteByPrimaryKey(Integer messageid);

    int insert(Message record);

    int insertSelective(Message record);

    @Select("select * from message where receiver=#{messageid} order by createtime desc" )
    List<Message> selectByPrimaryKey(String messageid);

    int updateByPrimaryKeySelective(Message record);

    int updateByPrimaryKey(Message record);

    @Select("select messageid from message where receiver=#{receiver}")
    List<Integer> getMessageByName(String receiver);

    @Delete("delete from message where messageid=#{id}")
    boolean deleteMessageById(int id);

    @Select("select messageid from message")
    List<Integer> getAllId();

    @Insert("insert into message(messageid,sender,receiver,messageinfo,createtime) values  (#{id},#{sender},#{receiver},#{msg},#{date})" )
    boolean insertMessage(int id, String sender, String receiver, String msg, Date date);

    @Select("select * from message where messageid=#{id}")
    Message selectMessagebyId(int id);
}